<?php

/**
 * @Descripttion : FOXCMS 是一款高效的 PHP 多端跨平台内容管理系统
 * @Author : FoxCMS Team
 * @Date : 2023/6/26   19:20
 * @version : V1.08
 * @copyright : ©2021-现在 贵州黔狐科技股份有限公司 版权所有
 * @LastEditTime : 2023/6/26   19:20
 */

namespace app\home\controller;

use app\common\controller\IndexBase;
use think\facade\View;

class Tags extends IndexBase
{
    protected $view_suffix; //文件后缀

    // 初始化
    protected function initialize()
    {
        parent::initialize();
        $id = $this->request->param("id");
        $Tag = \app\common\model\Tag::find($id);
        View::assign("tag", $Tag);
        $this->view_suffix = config('view.view_suffix');
    }

    public function index()
    {
        $param = $this->request->param();
        View::assign("taglist", $param);

        $tempHtml = "taglist.{$this->view_suffix}";
        if (($this->templateType == 2 || $this->templateType == 3) && is_mobile()) { //判断是否手机访问
            $tempHtmlMobile = $this->mobileHtml($tempHtml, $this->view_suffix);
            $tempHtmlMobilePath =  $this->templateHtml . $tempHtmlMobile;
            if (file_exists($tempHtmlMobilePath)) { //判断文件是否存在
                $tempHtml = $tempHtmlMobile;
            }
        }
        $template = $this->templateHtml . $tempHtml;
        $content = View::fetch($template);
        return access_stat_js($content, $this->domainNo);
    }

    // 标签详情
    public function  list()
    {
        $model_template = "list_tags.{$this->view_suffix}";
        if (($this->templateType == 2 || $this->templateType == 3) && is_mobile()) { //判断是否手机访问
            $model_templateMobile = $this->mobileHtml($model_template, $this->view_suffix);
            $model_templateMobilePath =  $this->templateHtml . $model_templateMobile;
            if (file_exists($model_templateMobilePath)) { //判断文件是否存在
                $model_template = $model_templateMobile;
            }
        }
        $template = $this->templateHtml . $model_template;
        $content = View::fetch($template);
        return access_stat_js($content, $this->domainNo);
    }
}
